package business.impl;

import java.sql.ResultSet;
import java.util.List;

import model.TPractice;
import model.TWorks;
import model.VWanted;
import model.VWorks;
import business.basic.iHibBaseDAO;
import business.basic.iHibBaseDAOImpl;
import business.dao.WorkDao;

public class WorkDaoIpml implements WorkDao {
	
	iHibBaseDAO bdao = null;
	public void setBdao (iHibBaseDAO bdao){
		this.bdao=bdao;
		
	}
	
	@Override
	public TWorks getWorkById(int id) {
		TWorks title = (TWorks) bdao.findById(TWorks.class,id);
		return title;
	}

	@Override
	public int addwork(TWorks model) {
		Object obj = bdao.insert(model);
		if (obj == null) {
			return 0;
		}
		return 1;
	}

	@Override
	public boolean upWork(TWorks model) {
		return bdao.update(model);
	}

	@Override
	public boolean delWork(int id) {
		return bdao.delete(TWorks.class, id);
	}

	@Override
	public List<VWorks> getWorksbyid(int stuid) {
		String sql = " from VWorks where stuinfoid = ? ";
		Object[] para = {stuid};
		List<VWorks> modl =  bdao.select(sql,para);
		return modl;
	}

	@Override
	public List<VWorks> getWorks() {
		String sql = "from VWorks   order by  createtime desc ";
		List<VWorks> modl =  bdao.select(sql);
		return modl;
	}

	@Override
	public VWorks getVWorkById(int id) {
		String sql = " from VWorks where worksid =   ?";
		Object[] para = {id};
		VWorks modl =   (VWorks) bdao.selectby(sql,para);
		return modl;
	}



}
